<?php
/**
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

/** @var $block \Magento\Braintree\Block\Creditcard\Management */
$storedCards = $block->getCurrentCustomerStoredCards();
?>
<div class="page-title title-buttons">
    <?php if ($block->getUsesVault()): ?>
        <button type="button" title="<?php echo $block->escapeHtml(__('Add Credit Card')); ?>"
                class="action subscribe primary"
                onclick="window.location='<?php echo $block->escapeUrl($block->getAddUrl()) ?>';">
            <span><span><?php echo $block->escapeHtml(__('Add Credit Card')); ?></span></span>
        </button>
    <?php endif; ?>
</div>
<?php echo $block->getLayout()->getMessagesBlock()->getGroupedHtml(); ?>
<?php if (count($storedCards)): ?>
    <table class="data-table" id="my-quotes-table">
        <col width="1" />
        <col width="1" />
        <col width="1" />
        <col width="1" />
        <col width="1" />
        <thead>
            <tr>
                <th><?php echo $block->escapeHtml(__('Type')); ?></th>
                <th><?php echo $block->escapeHtml(__('Card Number')); ?></th>
                <th><?php echo $block->escapeHtml(__('Is Default')); ?></th>
                <th colspan="2"><?php echo $block->escapeHtml(__('Actions')); ?></th>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($storedCards as $card):?>
                <tr>
                    <td><?php echo $block->escapeHtml($card->cardType); ?></td>
                    <td><?php echo $block->escapeHtml($card->maskedNumber); ?></td>
                    <td><?php /* @noEscape */ echo ($card->default) ? $block->escapeHtml(__('Yes')) : $block->escapeHtml(__('No')); ?></td>
                    <td>
                        <a href="<?php echo $block->escapeUrl($block->getEditUrl($card->token)); ?>">
                            <?php echo $block->escapeHtml(__('Edit')); ?>
                        </a>
                    </td>
                    <td>
                        <a href="<?php echo $block->escapeUrl($block->getDeleteUrl($card->token)); ?>">
                            <?php echo $block->escapeHtml(__('Delete'));?>
                        </a>
                    </td>
                </tr>
            <?php endforeach; ?>
        </tbody>        
    </table>
<?php endif; ?>
